package com.turing.post.webservice.impl;

import java.math.BigInteger;
import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.turing.post.antimoney.util.AlarmRule;
import com.turing.post.antimoney.util.AlarmRulesBusiness;
import com.turing.post.util.PCPSApplicationException;
import com.turing.post.util.PCPSUtil;

public class AlarmInfoTest {
	/**
	 * @param args
	 * @throws InterruptedException
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws InterruptedException {
		// 用户登录成功信息检测
		Context ctx = null;
		// 根据客户端传来的名字查找相应的实现EJB
		AlarmRulesBusiness arb = null;
		String name = "antimoney.impl.AlarmRule16" + "#"
				+ AlarmRulesBusiness.class.getName();

		Hashtable env = new Hashtable();
		env.put(InitialContext.INITIAL_CONTEXT_FACTORY,
				"weblogic.jndi.WLInitialContextFactory");
		env.put(InitialContext.PROVIDER_URL, "t3://192.168.1.234:7001");

		try {
			ctx = new InitialContext(env);
		} catch (NamingException e1) {
			e1.printStackTrace();
		}

		try {
			arb = (AlarmRulesBusiness) ctx.lookup(name);
		} catch (NamingException e) {
			e.printStackTrace();
		}
		// 961880134072 最初批次号 最终批次号961880134129
		String issuecompanyno = "961850";
		System.out.println("开始了");
		try {
			AlarmRule alarmRule = new AlarmRule();
			alarmRule.setAlarmRuleId(new BigInteger("16"));
			alarmRule.setAlarmRuleDesc("同一经办人在短时期内进行多次购买的未超过限额");
			alarmRule.setIssueCompanyNo(issuecompanyno);
			alarmRule.setJNDIName("antimoney.impl.AlarmRule16");
			alarmRule.setRuleParameter("2:2:3000000");
			alarmRule.setStatus("1");
			// alarmRule.setLastModifyTime(PCPSUtil.getDateYMDByString("2013/5/23
			// 14:13:58"));
			alarmRule.setLastOperId(new BigInteger("8"));
			alarmRule.setAlarmRuleType("0");
			alarmRule.setUdsiNo("1396");
			arb.runAlarmRules(issuecompanyno, PCPSUtil
					.getDateYMDByString("2013-05-11"), alarmRule);
		} catch (PCPSApplicationException e) {
			e.printStackTrace();
		}
		System.out.println("结束了");

	}

	@SuppressWarnings("unused")
	private static String StrFro(String batchNo, Integer i) {
		return batchNo + String.format("%06d", i);
	}
}
